package com.ld.zxw.config;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;

import redis.clients.jedis.Jedis;
/**
 * lucene 数据源
 * @author Administrator
 *
 */
public class LuceneDataSource {
	
	private static Logger log = Logger.getLogger(LuceneDataSource.class);
	
	private static Map<String, Object> dataSource = null;
	
	public static Jedis jedis = null;
	
	//默认不使用动态词典
	public static boolean DynamicDictionary = false;
	
	public LuceneDataSource() {
		dataSource = new HashMap<>();
	}
	
	public void addDataSource(Config config,String key){
		dataSource.put(key, config);
	}
	
	public static Config getConfig(String key) {
		if(StringUtils.isNotBlank(key)) {
			Object object = dataSource.get(key);
			if(object != null) {
				return (Config) object;
			}else {
				log.error("LuceneService 实例化失败", new Exception("sourceKey 不存在"));
				return null;
			}
		}else {
			log.error("LuceneService 实例化失败", new Exception("sourceKey 为空 "));
			return null;
		}
	}
	
}
